﻿<form action="index.php" method="post" name="addForm" >
<table>
	<tr style="border:1px solid silver">
		<td colspan="2" style="background:silver;"><h4><?php echo (isset($this->item->id)?'Cập nhật thông tin category':'Thêm category') ?></h4></td>
	</tr>
	<tr>
		<td>Tên	</td>
		<td>
			<input type="text" style="width:260px;" name="name" value="<?php echo @$this->item->name ?>" />		
		</td>
	</tr>
	<tr>
		<td>Danh mục cha</td>
		<td>
			<select name="parentid" >
			<option value="0">--Select--</option>
			<?php foreach($this->cats as $cat){ ?>
			<?php if($cat->id==@$this->item->parentid){ ?>
				<option value="<?php echo $cat->id ?>" selected><?php echo $cat->name ?></option>
			<?php }else{ ?>
				<option value="<?php echo $cat->id ?>"><?php echo $cat->name ?></option>
			<?php }}?>	
			</select>		
		</td>
	</tr>
	<tr>
		<td>
			Xuất bản
		</td>
		<td colspan="2">Có <input type="radio" <?php echo (@$this->item->published==1)?'checked':''; ?> name="published" <?php echo (!isset($this->item->published))?'checked':''; ?> value="1" /> Không <input name="published" type="radio"  <?php echo (@$this->item->published==0)?'checked':''; ?> value="0" /></td>
	</tr>
	<tr>
		<td>
			<input type="submit"  value="Save" />
			<input type="button" onclick="document.location.href='index.php?c=category';" value="Close" />
		</td>
	</tr>
</table>
<input type="hidden" name="c" value="category" />
<input type="hidden" name="t" value="proccessadd" />
<input type="hidden" name="id" value="<?php echo @(int)$this->item->id ?>" />
</form>
<script>
	function checkvalid()
	{
		if(document.addFrom.name.value=='')
			alert('Vui lòng nhập tên danh mục!');
		else
			document.addFrom.submit();
	}
</script>